import React from 'react'
// ===================================================================== Temp
import TableModal from '#cpt/temp/TableModal'
import TableControls from '#cpt/temp/TableControls'
import Confirm from '#cpt/temp/Confirm'
// ===================================================================== global declare
const { $fn, $http } = window
// ===================================================================== component
class Index extends React.Component{
	state = {
		data: [],
		enabled: [{ name: "已审核", value: "1" },{ name: "待审核", value: "0" }, { name: "待保存", value: "-2" } ]
	}
	
	query = {}
	
	open = ({uuid:spec_id,spec_code})=> {
		this.modal.open()
		this.query = { spec_id, spec_code }
		this.fetch()
	}
	
	fetch = ()=> {
		$http.pull(this,'specimen-kind/index',{ param:this.query}).then(data=>{
			this.setState({data})
		})
	}
	
	// 项目作废表单
	cols=[
		{ title: '项目代码', 	dataIndex: 'kind_code',		...$fn.table.spec_code,	 },
		{ title: '项目名称', 	dataIndex: 'kind_name', 	width:250 },
		{ title: '项目状态 ', 	dataIndex: 'enabled',  		width:100,  	render: text => $fn.getState(this.state.enabled,text)  },
		TableControls.controls.call(this,{ width: 80 }),
	]
		
	// 表格操作按钮
	table_controls = ({uuid}) => {
		return [
			Confirm.call(this, '删除', 'specimen-kind/end',{param: uuid} )
		]
	}
	
	render(){
		return TableModal.call(this,{ title:'项目作废', noSubmit:true, close:()=> this.props.onRefresh()})
	}
}

export default Index